
#include <assert.h>

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>

class MyQueue {
 public:
  MyQueue()
  {}

  void push(int x)
  {
    stack_.push(x);
  }

  int pop()
  {
    if (stack2_.empty()) { fuck(); }
    int a = stack2_.top();
    stack2_.pop();
    return a;
  }

  int peek()
  {
    if (stack2_.empty()) { fuck(); }
    return stack2_.top();
  }

  bool empty()
  {
    return stack2_.empty() && stack_.empty();
  }

 private:
  void fuck()
  {
    assert(stack2_.empty());
    while (!stack_.empty())
    {
      stack2_.push(stack_.top());
      stack_.pop();
    }
  }

 private:
  std::stack<int> stack_;
  std::stack<int> stack2_;
};

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue* obj = new MyQueue();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->peek();
 * bool param_4 = obj->empty();
 */
